program define xlab_months, rclass

	syntax , startmonth(string) endmonth(string) space(integer)
	
	
	forvalues m = `=monthly("`startmonth'","MY")'(`space')`=monthly("`endmonth'","MY")' {
		local month : di %tmMon `m'
		local year : di %tmCCYY `m'
		local year_prev : di %tmCCYY (`m' - `space')
		
		if (`"`xlab'"'=="" | `year'!=`year_prev') local xlab `xlab' `=dofm(`m')' `""`month' 1" "`year'""'
		else local xlab `xlab' `=dofm(`m')' "`month' 1"
	}
	
	return local xlab_months `xlab'
	
end
